package net.cachedb4j.service.impl;

import java.util.List;

import net.cachedb4j.dao.UserDao;
import net.cachedb4j.domain.User;
import net.cachedb4j.exception.UserExistedException;
import net.cachedb4j.service.DataSourceService;
import net.cachedb4j.service.UserService;

public class UserServiceImpl implements UserService {
	
	private UserDao userDao;

	private DataSourceService dataSourceService;

	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}
	
	public void setDataSourceService(DataSourceService dataSourceService) {
		this.dataSourceService = dataSourceService;
	}

	public void addUser(User user) throws UserExistedException {
		User e = userDao.getUserByUserName(user.getUsername());
		if(null == e) {
			userDao.save(user);
		} else
			throw new UserExistedException("usernam "+user.getUsername()+" already existed");
	}

	public void addUsers(List<User> user) {
		// TODO Auto-generated method stub
		
	}

	public void deleteUser(long id) {
		// TODO Auto-generated method stub
		
	}

	public void deleteUser(User user) {
		// TODO Auto-generated method stub
		
	}

	public void deleteUser(List<User> user) {
		// TODO Auto-generated method stub
		
	}

	public User getUserById(long id) {
		// TODO Auto-generated method stub
		return null;
	}

	public User getUserByUsername(String username) {
		// TODO Auto-generated method stub
		return null;
	}

	public User getUserByUsernameAndPassword(String username, String password) {
		// TODO Auto-generated method stub
		return null;
	}

	public User updateUser(User user) {
		// TODO Auto-generated method stub
		return null;
	}

	public void updateUsers(List<User> users) {
		// TODO Auto-generated method stub
		
	}

}
